package com.shg.web.action;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.shg.bean.PageView;
import com.shg.bean.QueryResult;
import com.shg.bean.SoldBook;
import com.shg.service.SoldBookService;
import com.shg.web.tools.WebTool;

@Controller
public class SoldBookAction {

	@Resource  SoldBookService soldBookService;
	//店铺的ID
	private String shopid;
	//查询的其实位置
	private int page=0;
	//查询的结束位置
	private int maxResult=3;
	//
	private String message;
	//分页显示
	private PageView<SoldBook> pageView;
	//店铺售出的所有书籍
	public String soldBook(){
		pageView=new PageView<SoldBook>(maxResult, page);
		QueryResult<SoldBook> queryResult;
		try {
			queryResult = soldBookService.getSoldBook(WebTool.getLogin().getId(), pageView.getFirstResult(), pageView.getMaxrecord());
		} catch (Exception e) {
			e.printStackTrace();
			this.message="操作发生异常";
			return "error";
		}
		pageView.setQueryResult(queryResult);
		return "soldBook";
	}

	public String getShopid() {
		return shopid;
	}

	public void setShopid(String shopid) {
		this.shopid = shopid;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getMaxResult() {
		return maxResult;
	}

	public void setMaxResult(int maxResult) {
		this.maxResult = maxResult;
	}

	public PageView<SoldBook> getPageView() {
		return pageView;
	}

	public void setPageView(PageView<SoldBook> pageView) {
		this.pageView = pageView;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
	
	
}
